import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Controls 1.4
import boan.qt.SerialBtn 1.0

ApplicationWindow {
    visible: true
    title: qsTr("Tabs")

    property bool isOn: false

    Component.onCompleted: showFullScreen()
//    Component.onCompleted: showMaximized()


    SerialBtn {
        id: sb
        onSigPowerOn: {
            if (isOn) {
                tabView.currentIndex = 0
                tabHome.children[0].resetAni()
                tabRoaster.children[0].resetAni()
                tabCookingGuide.children[0].resetAni()
                tabAutoSetting.children[0].resetAni()
                tabMenuMode.children[0].resetAni()
                isOn = false
            } else {
                tabView.currentIndex = 0
                tabHome.children[0].playAni()
                isOn = true
            }
        }

        onSigStart: {
            if (tabView.currentIndex == 3) {
                print("sigStaretf")
                tabAutoSetting.children[0].resetCircle()
                tabAutoSetting.children[0].startTask()
            } else if (tabView.currentIndex == 4) {
                tabMenuMode.children[0].startTask()
            }
        }
    }


    TabView {
        id: tabView
        anchors.fill: parent
        tabsVisible: false
        //        currentIndex: tabBar.currentIndex

        // 0
        Tab {
            id: tabHome
            active: true
            Page1Form {
                id: xxx
                onMoveToRoasterChicken: {
                    // tabView.addTab("tabRoaster", compRoaster)
                    tabView.currentIndex = 1
                    tabRoaster.children[0].playAni()
                }

                onGotoMenuMode: {
                    tabView.currentIndex = 4
                    tabMenuMode.children[0].playAni()
                }

                Component.onCompleted: {
//                    playAni()
                    resetAni()
                }
            }

        }

        // 1
        Tab {
            id: tabRoaster
            active: true
            RoastChickenMain {
                id: roaster
                Component.onCompleted: {
                    playAni()
                }

                onLeave: {
                    tabView.currentIndex = 0
                    tabHome.children[0].playAni()
                }

                onGotoCookingGuide: {
                    tabView.currentIndex = 2
                    tabCookingGuide.children[0].playAni()
                }

                onGotoAutoSetting: {
                    tabView.currentIndex = 3
                    tabAutoSetting.children[0].playAni()
                }

                onGotoTaste: {
                    tabView.currentIndex = 3
                    tabAutoSetting.children[0].playAniTaste()
                }

            }
        }

        // 2
        Tab {
            id: tabCookingGuide
            active: true
            CookingGuide {
                id: ssdx
                onBackFromCookingGuide: {
                    tabView.currentIndex = 1
                    tabRoaster.children[0].playAni()
                }
            }

        }

        // 3
        Tab {
            id: tabAutoSetting
            active: true
            AutoSetting {
                id: axx
                onBackFromAutoSetting: {
                    tabView.currentIndex = 1
                    tabRoaster.children[0].playAni()
                }

                onHome: {
                    tabView.currentIndex = 0
                    tabHome.children[0].playAni()
                }

            }
        }


        // 4
        Tab {
            id: tabMenuMode
            active: true
            MenuMode {
                id: xxxx
                onSigHome: {
                    tabView.currentIndex = 0
                    tabHome.children[0].playAni()
                }
            }
        }

    }

}



